# -*- coding:utf-8 -*-
"""
Author：Administrator
Date:2021年10月14日
"""
import pandas as pd

path = '../数据文件/课件030-031/同比.xlsx'

data = pd.read_excel(path, sheet_name='Sheet1')

yr = data['日期'].dt.year
data2 = pd.pivot_table(data, index='店号', values='金额', columns=yr, aggfunc='sum')

data2['同比'] = (data2[2019] - data2[2018])/data2[2018]

print(data2)